import { SHOP_CART } from '../constants'

const INITIAL_STATE = {
  cartList: [],
  invalidCartList: []
}

export default function cartState (state = INITIAL_STATE, action) {
  switch (action.type) {
    case SHOP_CART:
      let cartData = action.cartData || {}
      return {
        ...state,
        cartList: cartData.cartList || [],
        invalidCartList: cartData.invalidCartList || []
      }
    default:
      return state
      break
  }
}
